package cn.ljy.mes.web.controller.backstage.shop;


import cn.ljy.authority.web.controller.backstage.BaseBackstageController;
import cn.ljy.common.annotation.LimitRequest;
import cn.ljy.common.model.result.ResponseData;
import cn.ljy.mes.model.ShopCarOrder;
import cn.ljy.mes.model.query.ShopCarOrderQuery;
import cn.ljy.mes.service.ShopCarOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

@Api(tags = "后台商城汽车订单管理模块")
@RestController
@RequestMapping(value = "/backstage/shop/carOrder")
public class ShopCarOrderController extends BaseBackstageController<ShopCarOrder, ShopCarOrderQuery,String> {

    @Autowired
    private ShopCarOrderService baseService;

    @Override
    protected String getAuthorityPrefix() {
        return "shop:carOrder"; // 定义模块权限前缀
    }



    @ApiOperation(value = "订单状态管理")
    @PreAuthorize("hasAuthority('shop:carOrder:edit')")
    @LimitRequest
    @PatchMapping("/{orderId}/status")
    public ResponseData updateOrderStatus(@PathVariable String orderId,@NotBlank(message = "订单状态不能为空") String targetStatus) {
        baseService.changeStatus(orderId, targetStatus);
        return ResponseData.success(null);
    }
}
